﻿using System.Data.Entity;
using W2R.Core.Models.DataAccess;

namespace W2R.Core.DataAccess
{
    /// <summary>
    /// Unit of Work implemented with EF4 for W2R
    /// </summary>
    public class W2RUnitOfWork : IUnitOfWork
    {
        #region Constructor

        public W2RUnitOfWork()
        {
            this.Context = new W2RDataContext();
        }

        #endregion

        /// <summary>
        /// Persists the database changes
        /// </summary>
        public void Commit()
        {
            this.Context.SaveChanges();
        }

        public DbContext Context
        {
            get;
            private set;
        }

        public void Dispose()
        {
            this.Context.Dispose();
        }
    }
}
